package com.zcx.qshop;

import android.content.Context;

import com.zcx.helper.app.AppPreferences;
import com.zcx.qshop.conn.JsonAreaAsyGet;
import com.zcx.qshop.conn.JsonSchoolAsyGet;

/**
 * Created by Administrator on 2015/8/7 0007.
 */
public class QSPreferences extends AppPreferences {

    private String UID = "uid";

    private String IS_FIRST = "is_first";

    private String IS_GUIDE = "is_guide";

    private String CURRENT_SCHOOL_NAME = "current_school_name", CURRENT_SCHOOL_SID = "current_school_sid";

    private String CURRENT_CITY_NAME = "current_city_name", CURRENT_CIT_CID = "current_cit_cid";

    public QSPreferences(Context context) {

        super(context, "YC");

    }

    public void saveUid(String uid){

        putString(UID, uid);

    }

    public String readUid(){

        return getString(UID, "");

    }

    public void saveIsGuide(boolean isGuide){

        putBoolean(IS_GUIDE, isGuide);

    }

    public boolean readIsGuide(){

        return getBoolean(IS_GUIDE, false);

    }

    public void saveIsFirst(boolean isFirst){

        putBoolean(IS_FIRST, isFirst);

    }

    public void readIsFirst(){

        getBoolean(IS_FIRST, false);

    }

    public void saveCity(JsonAreaAsyGet.Area area){

        putString(CURRENT_CITY_NAME, area.name);

        putString(CURRENT_CIT_CID, area.code);

    }

    public JsonAreaAsyGet.Area readCity(){

        JsonAreaAsyGet.Area area = new JsonAreaAsyGet.Area();

        area.name = getString(CURRENT_CITY_NAME, "");

        area.code = getString(CURRENT_CIT_CID, "");

        return area;

    }

    public void saveSchool(JsonSchoolAsyGet.Info.School school){

        putString(CURRENT_SCHOOL_NAME, school.name);

        putString(CURRENT_SCHOOL_SID, school.sid);

    }

    public JsonSchoolAsyGet.Info.School readSchool(){

        JsonSchoolAsyGet.Info.School school = new JsonSchoolAsyGet.Info.School();

        school.name = getString(CURRENT_SCHOOL_NAME, "");

        school.sid = getString(CURRENT_SCHOOL_SID, "");

        return school;

    }

}
